﻿<%@ page contentType="text/html; charset=UTF-8"%>

<div style="padding: 8px;">
登录帐号
   <input id="s_sysuser_list_query_account" name="s_sysuser_list_query_account" type="text">&nbsp;&nbsp;
用户名称
   <input id="s_sysuser_list_query_name" name="s_sysuser_list_query_name" type="text">&nbsp;&nbsp;
   <input id="s_sysuser_list_query_btn" type="button" value="查　询">
</div>

<div style="padding: 4px;">
   <div><table id="sysuser_list_grid"></table></div>
   <div id="sysuser_list_grid_page"></div>
</div>

<div id="sysuser_list_dlg" class="easyui-dialog" title="管理用户信息">
   <form id="sysuser_list_dlg_form" name="sysuser_list_dlg_form" method="POST">
      <div id="sysuser_list_dlg_errmsg"></div>
      
      <table width="100%" align="center">
         <tr>
            <td align="right">登录帐号</td>
            <td align="left"><input id="sysuser_list_dlg_account" name="sysuser_list_dlg_account"/></td>
         </tr>
         <tr>
            <td align="right">用户名称</td>
            <td align="left"><input id="sysuser_list_dlg_name" name="sysuser_list_dlg_name" /></td>
         </tr>
         <tr>
            <td align="right">用户说明</td>
            <td align="left"><input id="sysuser_list_dlg_note" name="sysuser_list_dlg_note" /></td>
         </tr>
         <tr>
            <td align="right">状态</td>
            <td align="left">
               <select id="sysuser_list_dlg_status" name="sysuser_list_dlg_status" style="width: 120px">
                  <option value="0">无效</option>
                  <option value="1" selected>有效</option>
               </select>
            </td>
         </tr>

         <tr>
            <td colspan="2" align="center">
               <input type="button" id="sysuser_list_dlg_submit_btn" value="提　交"/>&nbsp;&nbsp;
               <input type="button" id="sysuser_list_dlg_close_btn" value="关　闭"/>
            </td>
         </tr>
      </table>
   </form>
</div>

<script>
   closeUIDialog('sysuser_list_dlg');
   
   var sysuser_list_save_flag = true;
   var sysuser_list_select_row;
   
   $('#sysuser_list_dlg_close_btn').unbind('click');
   $('#sysuser_list_dlg_close_btn').click(function()
   {
      closeUIDialog('sysuser_list_dlg');
   });
   
   $('#sysuser_list_dlg_submit_btn').unbind('click');
   $('#sysuser_list_dlg_submit_btn').click(function()
   {
      fun_sysuser_list_submit(); 
   });

   
   jQuery("#sysuser_list_grid").jqGrid(
   {
      caption: '系统管理用户' +
      '<a href="javascript:fun_sysuser_list_add()"  class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-edit\'">新增</a>' +
      '<a href="javascript:fun_sysuser_list_update()" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-save\'">修改</a>' +
      '<a href="javascript:fun_sysuser_list_delete()" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-cancel\'">删除</a>',
      datatype : "json",
      url : 'system/SysUser/list.do',
      autowidth: true,
      hidegrid : false,
      forceFit : true,
      height : '100%',
      width : '100%',
      
      colNames : ['编号', '登录帐号', '用户名称', '备注', '状态', '创建日期'],
      colModel : [
         { name : 'id', index : 'id', width :1, sorttype : 'int', sortable : false },
         { name : 'userAccount', index : 'userAccount', width : 90, sortable : false },
         { name : 'userName', index : 'userName', width : 90, sortable : false },
         { name : 'userNote', index : 'userNote', width : 180, sortable : false },
         { name : 'userStatus', index : 'userStatus', width : 60, sortable : false,
             formatter:'select',editoptions:{value:"0:无效;1:有效;"} },
         { name : 'registDateString', index : 'registDateString', width : 120, sortable : false}
      ],
      multiselect : false,
      toolbar : [ false, 'top' ],
      rowNum : 10,
      rowList : [ 10, 20, 50],
      rownumbers : true,
      viewrecords : true,
      sortname : "registDate",
      sortorder : "desc",
      pager : '#sysuser_list_grid_page',
      jsonReader :
      {
         root : 'dataRows',
         repeatitems : false
      }
   });
   
   jQuery("#sysuser_list_grid").jqGrid('hideCol', [ 'id' ]);

   function fun_sysuser_list_imgformat(cellvalue, options, rowObject)
   {  
      return '<img width=64 height=64 src="' + cellvalue + '" />';  
   }
   
   function fun_sysuser_list_add()
   {
	   sysuser_list_save_flag = true;
      $("#sysuser_list_dlg_form")[0].reset();  
      openUIDialog('sysuser_list_dlg', true, 320, 180);
   }
   
   function fun_sysuser_list_delete()
   {
      var gr = $("#sysuser_list_grid").jqGrid('getGridParam', 'selrow');
      if(gr)
       {
          var row_data = jQuery("#sysuser_list_grid").jqGrid('getRowData', gr);
         $.messager.confirm('删除提示','您确认要删除?',function(r)
         {   
            if(r)
            {
                 fun_sysuser_list_del(row_data.userId);
            }
         });
      }
      else
      {
         $.messager.alert('操作提示','请先选择用户再进行操作！');
      }
   }

   function fun_sysuser_list_del(user_ids)
   {
      var systemuserJson = new Object();
      systemuserJson.id = user_ids;
      systemuserJson.postType = 2;
         
      $.ajax( {
          async : false,
         type : "POST",
         url : "system/User/deleteUser.do",
         dataType : "json",
         data :
         {
              userJson : JSON.stringify(systemuserJson)
         },
         success : function(json)
         {
            if (json.success)
            {
               $("#sysuser_list_grid").trigger("reloadGrid");
               $.messager.alert('操作提示', "操作成功");
            }
            else
            {
               $.messager.alert('操作提示', '操作失败，请重试！');               
            }
         }
      });
   }

   $('#s_sysuser_list_query_btn').unbind('click');
   $('#s_sysuser_list_query_btn').click(function()
   {
      var s_custName = $('#s_sysuser_list_query_name').val();
      var s_custAccount = $('#s_sysuser_list_query_account').val();

      $("#sysuser_list_grid").setGridParam(
      {
         url : 'system/SysUser/list.do',
         mtype: 'post',
         postData:{'s_custName':s_custName, 's_custAccount':s_custAccount}
      });
      
      $("#sysuser_list_grid").trigger("reloadGrid");
   });

</script>
